<?php

declare(strict_types=1);

namespace App\CustHub\Mapper;

use App\CustHub\Model\ChUserMoneyLog;
use Mine\Abstracts\AbstractMapper;
use Mine\MineModel;
class ChGetMoneyLogMapper extends AbstractMapper
{
    public function assignModel(): void
    {
        $this->model = ChUserMoneyLog::class;
    }

    public function getMoneyLog($params): array
    {
        $filters = [
            'uid' => '=',
            'order_id' => '=',
            'business_type' => '='
        ];
        $query = $this->model::query()
            ->select(['id','uid','before','money','after','remark',
                'business_type','order_id','created_at'])
            ->orderBy('id','desc');
        $query = applyFilters($query,$params,$filters);
        $paginate = $query->paginate((int)$params['pageSize']??(MineModel::PAGE_SIZE));
        return $this->setPaginate($paginate);
    }
}